
//右边框显示隐藏及内容
var oListBottom=document.getElementById("list-bottom");
var aLi=oListBottom.getElementsByTagName("li");
var aJs1=document.getElementsByClassName("js-1");
var oUl1=document.getElementById("cake1-left");
var oUl2=document.getElementById("cake2-right");
var aA1=oUl1.getElementsByTagName("li");
var aA2=oUl2.getElementsByTagName("li");
for(var i=0;i<16;i++){
    aLi[i].index=i;
    aLi[i].onmouseover=function(){
        aLi[this.index].style.color="#e01222";
        aLi[this.index].style.backgroundColor="white";
        aJs1[this.index].style.display="block";
    }
    aLi[i].onmouseout=function () {
        aLi[this.index].style.color="white";
        aLi[this.index].style.backgroundColor="#2b2b2b";
        aJs1[this.index].style.display="none";
        var k=this.index;
        aJs1[this.index].onmouseover=function () {
            aLi[k].style.backgroundColor="white";
            aLi[k].style.color="#e01222";
            aJs1[k].style.display="block";
            for(var j=0;j<9;j++){
                aA1[j].index=j;
                aA1[j].onmouseover=function(){
                    //alert(this.index);
                    // aA1[this.index].style.backgroundColor="#e01222";
                }}
        }
        aJs1[this.index].onmouseout=function () {
            aLi[k].style.backgroundColor="#2b2b2b";
            aLi[k].style.color="white";
            aJs1[k].style.display="none";
        }
    }
}
//轮播图
var oLb=document.getElementById('img1');
var oPoint=document.getElementById('point');
var aLi4=oPoint.getElementsByTagName('li');
var num=0;
//向左MOVE
// function toL(){
//         num++;
//         var newLeft=oLb.offsetLeft-740;
//         if(num>3){
//             num=0;
//             newLeft=0;
//         }
//         oLb.style.left=newLeft+'px';
//     showCurrentPoint();
// }和下面的函数等价
//向左MOVE
function toL(){
    num++;
    if(num>3){
        num=0;
        oLb.style.left=-num*740+'px';
    }
    oLb.style.left=-num*740+'px';
    showCurrentPoint();
}
//point再点击时添加背景色
for(var i=0;i<aLi4.length;i++){
    aLi4[i].index=i;
    aLi4[i].onclick=function(){
        clearInterval(timer);
        for(var j=0;j<aLi4.length;j++){
            aLi4[j].className=''//把所有的控制按钮颜色都去掉
        }
        this.className='on';//当前点击的按钮变色
        oLb.style.left=-740*this.index+'px';
        num=this.index;
    }
}
//向右MOVE

function toR(){
    num--;
    if(num<0){
        num=3;
        oLb.style.left=-num*740+'px';
    }

    oLb.style.left=-num*740+'px';
    showCurrentPoint();
}

var timer=null;
var oBtnL=document.getElementById('btnL');
var oBtnR=document.getElementById('btnR');
timer=setInterval(function(){
    toL();
},800)
oLb.onmouseover=function(){
    clearInterval(timer);
    oBtnL.style.opacity='0.3';
    oBtnR.style.opacity='0.3';
    oBtnL.onmouseover=oBtnR.onmouseover=function(){
        clearInterval(timer);
        oBtnL.style.opacity='0.3';
        oBtnR.style.opacity='0.3';
        oBtnL.onclick=function(){
            toR();
        }
        oBtnR.onclick=function(){
            toL();
        }
    }
}
oLb.onmouseout=function(){
    timer=setInterval(toL,1000);
    oBtnL.style.opacity='0';
    oBtnR.style.opacity='0';
}
//point自动添加背景色
function showCurrentPoint(){
    for(var i=0;i<aLi4.length;i++){
        aLi4[i].className='';
    }
    aLi4[num].className='on';
}
//
// var oLb=document.getElementById('img1');
// var oPoint=document.getElementById('point');
// var aLi4=oPoint.getElementsByTagName('li');
// var index=0;
//
// function toR(){
//     index++;
//     if(index>3){index=0;}
//     var newLeft;
//     if(oLb.offsetLeft=='-2220'){
//         newLeft=0;
//     }
//     else{
//         newLeft=oLb.offsetLeft-740;
//     }
//     oLb.style.left=newLeft+'px';
//     showCurrentPoint();
// }
// function toL(){
//     index--;
//     if(index<0){index=3;}
//     var newLeft;
//     if(oLb.offsetLeft=='0'){
//         newLeft=-2220;
//     }else{
//         newLeft=oLb.offsetLeft+740;
//     }
//     oLb.style.left=newLeft+'px';
//     showCurrentPoint();
// }
//
// var timer=null;
// timer=setInterval(function(){
//     toR();
// },1000)
// oLb.onmouseover=function(){
//     clearInterval(timer);
// }
// oLb.onmouseout=function(){
//     timer=setInterval(toR,1000);
// }
// function showCurrentPoint(){
//     for(var i=0;i<aLi4.length;i++){
//         aLi4[i].className='';
//     }
//     aLi4[index].className='on';
// }

//右边添加背景色
var oPer=document.getElementById("per");
var oRight=document.getElementById("right");
var aLi2=oRight.getElementsByTagName("li");
var oMy=document.getElementById("MY");
var aP=oMy.getElementsByTagName("p");
var oRbg=document.getElementById("rbg");
aLi2[0].onmouseover=oPer.onmouseover=function(){
    oPer.style.display="block";
}
aLi2[0].onmouseout=oPer.onmouseout=function(){
    oPer.style.display="none";
}
aLi2[1].onmouseover=function(){
    oRbg.style.backgroundColor="white";
    oRbg.style.color="#e01222";
}
aLi2[1].onmouseout=function(){
    oRbg.style.backgroundColor="#e01222";
    oRbg.style.color="black";
}
for(i=2;i<8;i++){
    aLi2[i].index=i;
    aLi2[i].onmouseover=function(){
        // alert(this.index)
        oMy.style.display="block";
        aP[this.index-2].style.display="block";

    }
    aLi2[i].onmouseout=function(){
        aP[this.index-2].style.display="none";
        var a=this.index;
        aP[this.index-2].onmouseover=function () {
            aP[a-2].style.display="block";
            aP[a-2].style.color="#e01222";
        }
        aP[this.index-2].onmouseout=function () {
            aP[a-2].style.display="none";
            aP[a-2].style.color="#bfbfbf";
        }
    }
}





//特效图片边框阴影
var oNb=document.getElementsByClassName("next-bottom-b");
var oNc=document.getElementsByClassName("next-bottom-c");
var oNd=document.getElementsByClassName("next-bottom-d");
var oNe=document.getElementsByClassName("next-bottom-e");
for(var j=0;j<oNb.length;j++){
    var oImg=oNb[j].getElementsByTagName("img")[0];
    oImg.onmouseover=function(){

        this.style.width="320px";
        this.style.height="420px";
    }
    oImg.onmouseout=function(){
        this.style.width="300px";
        this.style.height="400px";
    }
}
for (var j=0;j<oNc.length;j++){
    var aImg1=oNc[j].getElementsByTagName("img");
    for(var i=0;i<2;i++){
        aImg1[i].onmouseover=function(){
            this.style.width="150px";
            this.style.height="150px";
            this.style.border="1px solid #d1d1d1";
            this.style.boxShadow=" 5px 5px 5px #d1d1d1";}
        aImg1[i].onmouseout=function(){
            this.style.width="140px";
            this.style.height="140px";
            this.style.border="none";
            this.style.boxShadow=" none";}
    }
}
for(var j=0;j<oNd.length;j++){
    var oImg2=oNd[j].getElementsByTagName("img")[0];
    oImg2.onmouseover=function(){
        this.style.width="210px";
        this.style.height="210px";
        this.style.border="1px solid #d1d1d1";
        this.style.boxShadow=" 5px 5px 5px #d1d1d1";
    }
    oImg2.onmouseout=function(){
        this.style.width="200px";
        this.style.height="200px";
        this.style.border="none";
        this.style.boxShadow=" none";
    }
}
for(var j=0;j<oNe.length;j++){
    var aImg3=oNe[j].getElementsByTagName("img");
    for(var i=0;i<2;i++){
        aImg3[i].onmouseover=function(){
            this.style.width="150px";
            this.style.height="150px";
            this.style.border="1px solid #d1d1d1";
            this.style.boxShadow=" 5px 5px 5px #d1d1d1";}
        aImg3[i].onmouseout=function(){
            this.style.width="140px";
            this.style.height="140px";
            this.style.border="none";
            this.style.boxShadow=" none";}
    }
}
//倒计时
function addZero(t){
    return t= t<10 ? "0"+t : ""+t;
}
var aTimeIndex=document.getElementsByClassName("time-index")[0];
var aDjsLi=aTimeIndex.getElementsByTagName("li");
var endTime=new Date(2017,11,12,0,0,0);
function daojishi () {
    var nowTime=new Date();
    var t= Math.floor((endTime-nowTime)/1000);
    var strD1=Math.floor(t/86400)+"天";//天
    var strD2=addZero(Math.floor(t%86400/3600))+"时";//时
    var strD3=addZero(Math.floor(t%3600/60))+"分"//分
    var strD4=addZero(t%60)+"秒";//秒
    aDjsLi[0].innerHTML=strD1;
    aDjsLi[1].innerHTML=strD2;
    aDjsLi[2].innerHTML=strD3;
    aDjsLi[3].innerHTML=strD4;
}
daojishi();
setInterval(daojishi,1000);
//回顶部
var oClick=document.getElementById('r-click');
oClick.onclick = function(){
    document.body.scrollTop = document.documentElement.scrollTop = 0;//可视区距页面顶端距离
}